package com.banyuan;

import java.io.*;

public class ObjecInputStreamTest {
    public static void main(String[] args) {
        InputStream is = null;
        ObjectInputStream ois = null;


        try {
            is = new FileInputStream("/Users/edy/Desktop/file/obj.txt");
            ois = new ObjectInputStream(is);
            Object obj;
            while ((obj = ois.readObject()) != null) {
                // 要在写入的最后写入一个null，因为jvm认为null也是对象
                System.out.println(obj);
            }

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } finally {
            IOUtilis.closeQuiety(ois);
            IOUtilis.closeQuiety(is);
        }



    }
}
